import axios from "axios";
import React from "react";

const Index = () => {
  const orederID = new Date().getTime() + 123;
  const address = "上海八维宏烨校区";
  const tel = "13111111111";
  const user = "张三";
  const price = 200;
  const title = "电子消费-手机-11-123";

  const submit = async () => {
    const resp = await axios.post("/api/order/pay", {
      orederID,
      address,
      tel,
      user,
      price,
      title,
    });

    window.location.href = resp.data.data;
    console.log(resp.data.data);
  };

  return (
    <div>
      <div>
        <span>订单id: {orederID}</span>
      </div>
      <div>
        <span>订单地址：{address}</span>
      </div>
      <div>
        <span>联系方式：{tel}</span>
      </div>
      <div>
        <span>用户: {user}</span>
      </div>
      <div>
        <span>金额: {price}</span>
      </div>
      <div>
        <span>title: {title}</span>
      </div>
      <button onClick={submit}>立即支付</button>
    </div>
  );
};

export default Index;
